package org.coding.springbootdemorabbitmq.producer;

import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

/**
 * ^ enjoy coding and be bugfree boy
 *
 * @author guoxh
 * @date 2020/11/12 12:13 上午
 * @desc
 **/
@Component
public class DirectSender {
    @Autowired
    private AmqpTemplate amqpTemplate;

    @Value("${mq.config.exchange}")
    private String exchange;

    @Value("${mq.config.queue.info.routingkey}")
    private String inforouteKey;
    @Value("${mq.config.queue.err.routingkey}")
    private String errrouteKey;

    public void sendInfoMsg(String msg){
        this.amqpTemplate.convertAndSend(exchange,inforouteKey,msg);
    }

    public void sendErrMsg(String msg){
        this.amqpTemplate.convertAndSend(exchange,errrouteKey,msg);
    }
}
